package com.cx.config;

import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.annotation.MapperScan;
import org.mybatis.spring.mapper.MapperScannerConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

import javax.sql.DataSource;
@Component
@PropertySource("classpath:jdbc.properties")
@MapperScan("com.cx.mapper")
public class MybatisConfig {
    @Bean
    public SqlSessionFactoryBean  sqlSessionFactoryBean (DataSource dataSource){
        SqlSessionFactoryBean FactoryBean = new SqlSessionFactoryBean();
        FactoryBean.setDataSource(dataSource);
//        FactoryBean.setTypeAliasesPackage("com.cx.entity");
        return FactoryBean;
    }
//@Bean
//    public MapperScannerConfigurer mapperScannerConfigurer(){
//        MapperScannerConfigurer configurer = new MapperScannerConfigurer();
//    configurer.setBasePackage("com.cx.mapper");
//    return configurer;
//    }

}
